  function initPopup() {

	/*			PF LIST 				   */
    /* =================================== */
	    
	    $("#windowClientiPFListPopup").kendoWindow({
		    width: "850px",
		    //height: "650px",
		    title: "Selectati Persoana Fizica",
		    //content: "clientiPFListPopup",
		    visible: false,
		    modal: true	    
		});
    
	    var windowClientiPFListPopup = $("#windowClientiPFListPopup").data("kendoWindow");
    
		$("#ShowPFSelectPopupANCHETA").bind("click", function() {
			windowClientiPFListPopup.refresh({
			    url: "clientiPFListPopup",
			    data: { returnEntity: "ANCHETA" }
			});
			windowClientiPFListPopup.center();
			windowClientiPFListPopup.open();
	    });
		
		$("#ShowPFSelectPopupCONTRACT").bind("click", function() {
			windowClientiPFListPopup.refresh({
			    url: "clientiPFListPopup",
			    data: { returnEntity: "CONTRACT" }
			});
			windowClientiPFListPopup.center();
			windowClientiPFListPopup.open();
	    });
		
		
		
	/*			PF CARD 				   */
    /* =================================== */
		$("#windowClientiPFCardPopup").kendoWindow({
		    width: "850px",
		    //height: "650px",
		    title: "Adaugati Persoana Fizica",
		    //content: "clientiPFCardPopup",
		    visible: false,
		    modal: true	    
		});
		
		var windowClientiPFCardPopup = $("#windowClientiPFCardPopup").data("kendoWindow");
	    
		$("#ShowPFAddPopupANCHETA").bind("click", function() {
			
			windowClientiPFCardPopup.refresh({
			    url: "clientiPFCardPopup",
			    data: { returnEntity: 	"ANCHETA", 
			    		pfId:			$("#pId").val() 
			    		}
			});
			
			windowClientiPFCardPopup.center();
			windowClientiPFCardPopup.open();
			
	    });
		
		$("#ShowPFAddPopupCONTRACT").bind("click", function() {
			windowClientiPFCardPopup.refresh({
			    url: "clientiPFCardPopup",
			    data: { returnEntity: "CONTRACT" , 
		    			pfId:			$("#cId").val()}
			});
			windowClientiPFCardPopup.center();
			windowClientiPFCardPopup.open();
			
	    });
		
		
	/* =================================== */	
		
		
	/*			PJ LIST 				   */
    /* =================================== */	
		$("#windowClientiPJListPopup").kendoWindow({
		    width: "850px",
		    //height: "650px",
		    title: "Selectati Persoana Juridica",
		    //content: "clientiPJListPopup",
		    visible: false,
		    modal: true	  		
		});
		
		var windowClientiPJListPopup = $("#windowClientiPJListPopup").data("kendoWindow");
		
		
		$("#ShowPJSelectPopupANCHETA").bind("click", function() {
			windowClientiPJListPopup.refresh({
			    url: "clientiPJListPopup",
			    data: { returnEntity: "ANCHETA" }
			});
			windowClientiPJListPopup.center();
			windowClientiPJListPopup.open();
	    });
		
		$("#ShowPJSelectPopupCONTRACT").bind("click", function() {
			windowClientiPJListPopup.refresh({
			    url: "clientiPJListPopup",
			    data: { returnEntity: "CONTRACT" }
			});
			windowClientiPJListPopup.center();
			windowClientiPJListPopup.open();
	    });
		/*			PJ CARD 				   */
	    /* =================================== */
	    
		$("#windowClientiPJCardPopup").kendoWindow({
		    width: "850px",
		    //height: "650px",
		    title: "Adaugati Persoana Juridica",
		    //content: "clientiPJCardPopup",
		    visible: false,
		    modal: true	    
		});
		
		var windowClientiPJCardPopup = $("#windowClientiPJCardPopup").data("kendoWindow");
	    
		$("#ShowPJAddPopupANCHETA").bind("click", function() {
			windowClientiPJCardPopup.refresh({
			    url: "clientiPJCardPopup",
			    data: { returnEntity: "ANCHETA"  ,  
	    				pjId:			$("#ppId").val() }
			});
			windowClientiPJCardPopup.center();
			windowClientiPJCardPopup.open();
			
	    });
		
		$("#ShowPJAddPopupCONTRACT").bind("click", function() {
			windowClientiPJCardPopup.refresh({
			    url: "clientiPJCardPopup",
			    data: { returnEntity: "CONTRACT",    
    					pjId:			$("#cpId").val()  }
			});
			windowClientiPJCardPopup.center();
			windowClientiPJCardPopup.open();
			
	    });		
		
// 		var validator;
// 		var status;	
// 		 validator = $("#formContractCard").kendoValidator().data("kendoValidator");
// 		 status = 	$(".status");

		$('#pIdnp').attr('readonly', 'readonly');
		$('#pLastName').attr('readonly', 'readonly');
		$('#pFirstName').attr('readonly', 'readonly');
		$('#pPatronymic').attr('readonly', 'readonly');
		$('#pBirthDate').attr('readonly', 'readonly');
		$('#pAddress').attr('readonly', 'readonly');
		$('#pOcupatia').attr('readonly', 'readonly');
		$('#pPhoneHome').attr('readonly', 'readonly');
		$('#pPhoneServ').attr('readonly', 'readonly');
		$('#pPhoneMob').attr('readonly', 'readonly');
		$('#pEmal').attr('readonly', 'readonly');
		$('#pSkype').attr('readonly', 'readonly');

		$('#cIdnp').attr('readonly', 'readonly');
		$('#cLastName').attr('readonly', 'readonly');
		$('#cFirstName').attr('readonly', 'readonly');
		$('#cPatronymic').attr('readonly', 'readonly');

		$('#ppIdno').attr('readonly', 'readonly');
		$('#ppCompanyName').attr('readonly', 'readonly');
		$('#ppBossNameSurname').attr('readonly', 'readonly');
		$('#ppAddress').attr('readonly', 'readonly');
		$('#ppAddressJ').attr('readonly', 'readonly');
		$('#ppPhoneMob').attr('readonly', 'readonly');
		$('#ppPhoneServ').attr('readonly', 'readonly');
		$('#ppSkype').attr('readonly', 'readonly');
		$('#ppEmal').attr('readonly', 'readonly');
		$('#ppCompanySite').attr('readonly', 'readonly');

		$('#cpIdno').attr('readonly', 'readonly');
		$('#cpCompanyName').attr('readonly', 'readonly');
		
		$('#pContractNo').attr('readonly', 'readonly');
		
// 		$("#pContractDate").data("kendoDatePicker").enable(false);
// 		$("#pAppRegDateDate").data("kendoDatePicker").enable(false);
		
//		$('#pContractDate').attr("readonly", "readonly");
		$('#pAppRegDateDate').attr("readonly", "readonly");
  }
  
  
  
	function getRegPersonApp (pId){
		console.log("-----------*****----------- pId = " + pId  );	
	
		$.ajax({
			  url: "json/regPersons",
			  dataType: 'json',
			  type: 'POST',
			  data: { id: pId },
			  success: function (response) {
   
//	 		      alert(response.idnp);
	 		    $("#pId").val(response.id);
				$("#pIdnp").val(response.idnp);
				$("#pLastName").val(response.lastName);
				$("#pFirstName").val(response.firstName);
				$("#pPatronymic").val(response.patronymic);
				$("#pBirthDate").val(response.birthDate);
				$("#pAddress").val(response.address);
				$("#pOcupatia").val(response.ocupatia);
				$("#pPhoneHome").val(response.phoneHome);
				$("#pPhoneServ").val(response.phoneServ);
				$("#pPhoneMob").val(response.phoneMob);
				$("#pEmal").val(response.emal);
				$("#pSkype").val(response.skype);
	 		      
	 		      
			  }
		  });
		console.log("-----------+++++++++++-----------");	
	}
	
	function getRegPersonContr (pId){
		$.ajax({
			  url: "json/regPersons",
			  dataType: 'json',
			  type: 'POST',
			  data: { id: pId },
			  success: function (response) {

	 		    $("#cId").val(response.id);
				$("#cIdnp").val(response.idnp);
				$("#cLastName").val(response.lastName);
				$("#cFirstName").val(response.firstName);
				$("#cPatronymic").val(response.patronymic);
				
				$("#cpId").val(null);
				$("#cpIdno").val(null);
				$("#cpCompanyName").val(null);
				
			  }
		  });
	}
	
	function getRegCompanysApp (pId){
		$.ajax({
			  url: "json/regCompanies",
			  dataType: 'json',
			  type: 'POST',
			  data: { id: pId },
			  success: function (response) {
				$("#ppId").val(response.id);
				$("#ppIdno").val(response.idno);
				$("#ppCompanyName").val(response.companyName);
				$("#ppCompanyFondDate").val(response.foundationDate);
				$("#ppBossNameSurname").val(response.bossNameSurname);
				$("#ppBossBirthDate").val(response.bossBirthDate);
				$("#ppAddress").val(response.address);
				$("#ppAddressJ").val(response.juridicAddress);
				$("#ppPhoneMob").val(response.phoneMob);
				$("#ppPhoneServ").val(response.phoneServ);
				$("#ppSkype").val(response.skype);
				$("#ppEmal").val(response.emal);
				$("#ppCompanySite").val(response.companySite);
				
			  }
		  });
	}
	
	function getRegCompanysContr (pId){
		$.ajax({
			  url: "json/regCompanies",
			  dataType: 'json',
			  type: 'POST',
			  data: { id: pId },
			  success: function (response) {
				$("#cpId").val(response.id);
				$("#cpIdno").val(response.idno);
				$("#cpCompanyName").val(response.companyName);
				
				$("#cId").val(null);
				$("#cIdnp").val(null);
				$("#cLastName").val(null);
				$("#cFirstName").val(null);
				$("#cPatronymic").val(null);
				
			  }
		  });
	} 